package com.jinxin.platform.cdacscontrolmgr.controller;

import com.jinxin.platform.base.api.annotation.APCOSApi;
import com.jinxin.platform.base.api.annotation.APCOSApiOperation;
import com.jinxin.platform.base.api.constant.APCOSApiConstans;
import com.jinxin.platform.cdacscontrolmgr.service.ICdacscontrolkmgrCxlfRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * All rights Reserved, Designed By www.beonelot.com
 *
 * @version: V1.0
 * @Copyright: www.beonelot.com Inc. All rights reserved.
 * @Description：
 * @Date: 2021-09-15
 * @Author: Lingnan
 **/
@APCOSApi(value = "车行来访记录接口", developers = {"lingnan"}, description = "车行来访记录接口")
@RestController
@RequestMapping("/cdacscontrolmgr/cdacscontrolmgrCxlfRecord")
@Slf4j
public class CdacscontrolmgrCxlfRecordController {
    @Autowired
    ICdacscontrolkmgrCxlfRecordService cxlfRecordService;

    @APCOSApiOperation(value = "分页查询车行来访记录", developers = {"lingnan"}, description = "分页查询车行来访记录",
            infType = APCOSApiConstans.INF_TYPE_OTHER, infCategory = APCOSApiConstans.INF_CATEGORY_ALL)
    @GetMapping("/list")
    public Map<String,Object> list(@RequestParam int page, @RequestParam int limit,
                                   @RequestParam(name = "projectId")String projectId,
                                   @RequestParam(required = false,name = "owner")String owner,
                                   @RequestParam(required = false,name = "carNo")String carNo,
                                   @RequestParam(required = false,name = "phone")String phone,
                                   @RequestParam(required = false,name = "startDate")String startDate,
                                   @RequestParam(required = false,name = "endDate")String endDate){
        Map<String,Object> resultMap = new HashMap<>();
        resultMap.put("code",0);
        resultMap.put("msg","success");
        HashMap param = new HashMap();
        param.put("page", page);
        param.put("limit", limit);
        param.put("projectId", projectId);
        param.put("owner", owner);
        param.put("carNo", carNo);
        param.put("phone", phone);
        param.put("startDate", startDate);
        param.put("endDate", endDate);
        resultMap.put("count", cxlfRecordService.listPageCount(param));
        resultMap.put("data", cxlfRecordService.listPage(param));
        return resultMap;
    }

}
